using Assets.Scripts.GDK;
using System.Collections;
using UnityEngine;

namespace Brick
{
	public class CopyBall : MonoBehaviour
	{
		public TiggerBox trigger;

		private bool isRecive;

		public bool GetTrigger()
		{
			return trigger.isTrigger;
		}

		private void OnEnable()
		{
			trigger.isTrigger = false;
			isRecive = false;
		}

		private void OnCollisionEnter2D(Collision2D collision)
		{
		}

		private void OnTriggerEnter2D(Collider2D other)
		{
			UnityEngine.Debug.Log("Triger ");
			if (!trigger.isTrigger && !isRecive)
			{
				isRecive = true;
				gdk_game_manager.PlaySound(AudioID.balladdone);
				trigger.isTrigger = true;
				Vector3 localPosition = base.gameObject.transform.localPosition;
				base.gameObject.transform.localPosition = new Vector3(localPosition.x, -430f, 0f);
				StartCoroutine(LineLaunch(base.gameObject.transform));
			}
		}

		private IEnumerator LineLaunch(Transform other)
		{
			yield return new WaitForSeconds(1.1f);
			gdk_game_manager.DispachEvent(EventID.GAME_LIT_ADD_BALL, 1);
			EnemyPool.GetInstance().RecycleObj(base.gameObject);
			UnityEngine.Object.Destroy(base.gameObject);
		}
	}
}

